package com.jihu.design.behavioral.interpreter;

import java.util.Set;

/**
 * 终结表达式
 * @author jihu
 * @date 2021/10/9
 */
public class TerminalExpression extends IDCardExoression {

    Set<String> data; //数据
    String symbol; //解析符号

    public TerminalExpression(Set<String> data,String symbol){
        this.data = data;
        this.symbol = symbol;
    }

    @Override
    boolean interpret(String expression) {
        //先按照指定符号分割
        String[] split = expression.split(symbol);
        for (String s : split) {
            if(data.contains(s)){
                return true;
            }
        }
        return false;
    }
}
